import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt(), x=  scanner.nextInt();
        int[] A = new int[n];
        for (int i = 0; i < n; i++) {
            A[i] = scanner.nextInt();
        }

    }

    private static int findMinOp(int[] A, int n , int x){
        int sum = 0 ;
        for(int num : A) sum += num;
        if(sum % x == 0) return 0;

        int minOp = Integer.MAX_VALUE;
        boolean canRemove = false;
        for (int i = 0; i < n; i++) {
            if(A[i] % x != 0){
                canRemove = true;
                minOp = Math.min(minOp,1);
            }
        }
        //没有可以删除的
        if(!canRemove) return -1;

        //计算增加元素的最少操作数
        for (int i = 0; i < n; i++) {
            int tmp = (x - (sum % x)) % x;
            if((A[i] + tmp)  % x == 0){
                minOp = Math.min(minOp , tmp);
            }
        }
        return minOp;
    }
}
